<template>
    <div class="feedback flexv">
        <!-- 头部 -->
        <pubHead title="意见反馈" ></pubHead>

        <div class="init_title mt2">反馈内容</div>
        <textarea class="init_text" placeholder="请输入遇到的问题或建议..." maxlength="150" v-model="content"></textarea>

        <div class="submit white tc" @click="submit">提交</div>
    </div>
</template>
<script>
import Vue from 'vue';
import pubHead from '@/components/head';
import { u_Reg } from '@/config/utils.js';
import { Toast } from 'vant';
import { feedBack } from '@/request/api';

Vue.use(Toast )
export default {
    data(){
        return{
            once: true, // 防止重复提交
            content: '', // 反馈内容
        }
    },
    components: {
        pubHead,
    },
    created(){},
    methods: {
        // 获取数据
        getData(){
        },
        // 提交
        submit(){
            if(!this.content){
                this.$tip('请输入您要反馈的内容!');
                return
            }

            this.$loading('意见提交中...');
            if(this.once){
                this.once = false;
                feedBack({
                    token: localStorage.getItem("token"),
                    content: this.content
                }).then(res =>{
                    Toast.clear();
                    this.$tip(res.msg);
                    this.once = true;
                    if(res.code == 1){
                        setTimeout(() =>{
                            this.$router.go(-1)
                        },1200)
                    }
                })
            }
        },
    },
}
</script>
<style lang="less" scoped>
.feedback{
    min-height: 100vh;
    background-color: #f5f5f5;
    .init_title{
        height: 0.9rem;
        padding: 0 0.3rem;
        font-size: 0.3rem;
        line-height: 0.9rem;
        color: #333;
        border-bottom: 0.01rem solid #eee;
        background-color: #fff;
    }
    .init_text{
        height: 3.18rem;
        padding: 0.2rem 0.3rem;
        font-size: 0.3rem;
        line-height: 150%;
        color: #333;
        resize: none;
        word-break: break-all;
    }
    .submit{
        width: 6.9rem;
        height: 0.88rem;
        margin: 1.4rem auto 0;
        font-size: 0.32rem;
        line-height: 0.88rem;
        border-radius: 0.44rem;
        background-color: #57B127;
    }
}
</style>